package com.free.mini.gateway.utils.encryption;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AndroidBase64Utils {
    private static final String TAG = "AndroidBase64Utils";
    private static final boolean DEBUG = true;
    public static String encode(String str) {
        String result = "";
        if( str != null) {
            result = new String(AndroidBase64.encode(str.getBytes(StandardCharsets.UTF_8),AndroidBase64.NO_WRAP), StandardCharsets.UTF_8);
        }
        return result;
    }

    public static String encode(byte[] bytes){
        String result = "";
        if( bytes != null) {
            result = new String(AndroidBase64.encode(bytes,AndroidBase64.NO_WRAP), StandardCharsets.UTF_8);
        }
        return result;
    }

    public static String encodeAndroidBase64(byte[] bytes){
        String result = "";
        if( bytes != null) {
            result = new String(AndroidBase64.encode(bytes,AndroidBase64.NO_WRAP), StandardCharsets.UTF_8);
        }
        return result;
    }

    public static byte[] decode(String str) {
       return AndroidBase64.decode(str.getBytes(),AndroidBase64.NO_WRAP);
    }
}